package com.test.javafaq_sys.controller;

import com.test.javafaq_commons.entity.Permission;
import com.test.javafaq_commons.entity.Role;
import com.test.javafaq_commons.entity.User;
import com.test.javafaq_sys.service.IUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/v1/auth")
@Slf4j
public class AuthController {


    @Resource
    IUserService userService;
    //  /v1/auth/user
    @GetMapping("/user")
    public User getUser(String username){
        return userService.getUserByUsername(username);
    }
    @GetMapping("/permissions")
    public List<Permission> getPermissions(Integer userId){
        return userService.getUserPermissions(userId);
    }

    @GetMapping("/roles")
    public List<Role> getRoles(Integer userId){
        return userService.getUserRoles(userId);
    }

}
